﻿using ZeroBug.EasyFlow.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZeroBug.EasyFlow.Steps
{
    public class GroupStep : IStep
    {
        public bool IgnoreChildren { get; set; } = false;
        public string Icon { get; set; } = "List";
        public bool IsSingleRun { get; set; } = false;
        public int ChildrenIndex { get; set; }
        public Core.Step? NextStep { get; set; }
        public bool Compile(FlowBase flow, ZeroBug.EasyFlow.Core.Step step, out string errInfo)
        {
            errInfo = string.Empty;
            return true;
        }

        public object GetForm()
        {
            return new GroupStepForm();
        }

        public StepInfo GetInfo()
        {
            StepInfo info = new StepInfo();
            info.StepName = "Group";
            info.Group = StepGroup.Control;
            info.ImagePath = "pack://application:,,,/ZeroBug.EasyFlow.Step;component/Images/条件.png";
            return info;
        }

        public void OnChildrenEnter()
        {
        }

        public void OnChildrenLeave()
        {

        }

        public bool Prepare(FlowBase flow, ZeroBug.EasyFlow.Core.Step step, out string errInfo)
        {
            errInfo = string.Empty;
            return true;
        }

        public void RegisterVariables(FlowBase flow, ZeroBug.EasyFlow.Core.Step step)
        {
        }

        public StepResult Run(FlowBase flow, ZeroBug.EasyFlow.Core.Step step, out string errInfo)
        {
            errInfo = "";
            //Thread.Sleep(2000);

            return StepResult.Success;
        }

        public string GetTip(Core.Step step)
        {
            return step.Tip;
        }

        public (SerializableDictionary<string, VariableExpression>, List<VariableJudge>) GetParametersAndConditions()
        {
            throw new NotImplementedException();
        }

        public void UnRegisterVariables(FlowBase flow, Core.Step step)
        {
        }
    }
}
